<div class="content-table">
    <?php
        echo $this->partial('topo_list.phtml', array(
            'titulo' => $this->titulo,
            'controller' => $this->controller, 
            'search' => $this->search,
            'add'   =>  FALSE, 
            'form_search' => FALSE,
        ));
    ?> 
    <table id="tlist" class="tb_content">
        <thead>
            <tr>
                <th>Curso</th>
                <th>Data Compra</th>
                <th>Data de Término</th>
                <th>Dias de Acesso</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
                $cur = $row->findDependentRowSet("Ead_Model_DbTable_Curso");
                $COM_DATPAG = explode('-', $row->COM_DATPAG);
                $timestamp1 = mktime(0,0,0,$COM_DATPAG[1], $COM_DATPAG[2] + $cur[0]['CUR_QTDDIAACE'], $COM_DATPAG[0]);
                $timestamp2 = mktime(0,0,0,date('m'), date('d'), date('Y'));
                $segundos_diferenca = $timestamp1 - $timestamp2;
                $dias_diferenca =  1 + ( $segundos_diferenca / (60 * 60 * 24) );
                $dias_diferenca = floor($dias_diferenca);

                
                $datafim = date("d/m/Y", mktime(0,0,0, date('m'), date('d') + $cur[0]['CUR_QTDDIAACE'], date('Y') ) );
                        
    
                ?>
                <tr>  
                    <td align="left"><?php echo $cur[0]['CUR_NOM']; ?></td>
                    <td><?php echo Datetools::invert($row->COM_DATPAG); ?></td>
                    <td align="left"><?php 
                        echo $datafim;
                    ?></td>
                    <td align="left"><?php echo $dias_diferenca; ?></td>
                    <td>
                        <a class="btn-book-list" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'conteudo', 'cur_id' => $row->CUR_ID)); ?>">Conteúdo</a>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>